[LINUX] netfront: Don't call netif_carrier_off until the device is
authorIan Campbell <ian.campbell@xensource.com>
Thu, 1 Feb 2007 10:20:34 +0000 (10:20 +0000)
committerIan Campbell <ian.campbell@xensource.com>
Thu, 1 Feb 2007 10:20:34 +0000 (10:20 +0000)
fuly allocated.

netif_carrier_off() causes events to be queued on the device so if we
subsequently abort the allocation (e.g. due to lack of grant entries)
then we crash trying to access the now invalid device.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c

index f54cc84b89f9d59c7c154650bfb0ff8da62ea8fb..bd86948fed5c4096aab8c813a679c093248395cc 100644 (file)
@@ -1935,8 +1935,6 @@ static struct net_device * __devinit create_netdev(struct xenbus_device *dev)
        np                   = netdev_priv(netdev);
        np->xbdev            = dev;
 
-       netif_carrier_off(netdev);
-
        spin_lock_init(&np->tx_lock);
        spin_lock_init(&np->rx_lock);
 
@@ -1991,6 +1989,9 @@ static struct net_device * __devinit create_netdev(struct xenbus_device *dev)
        SET_NETDEV_DEV(netdev, &dev->dev);
 
        np->netdev = netdev;
+
+       netif_carrier_off(netdev);
+
        return netdev;
 
  exit_free_tx: